﻿using System;
using System.Collections.Generic;
using Newtonsoft.Json;

namespace AisinGioro.Core.DTOs
{
    public abstract class BaseHostDto
    {
        [JsonProperty("hostId", Order = 0)]
        public string HostId { get; set; }
    }

    /// <summary>
    /// 心跳包
    /// </summary>
    [Serializable]
    public class HeartbeatDto : BaseHostDto
    {
        [JsonProperty("isAlive")]
        public bool IsAlive { get; set; }
    }

    /// <summary>
    /// 磁盘信息
    /// </summary>
    [Serializable]
    public class DiskInfoDto : BaseHostDto
    {
        [JsonProperty("items")]
        public IList<DiskInfoItem> Items { get; set; }

        public DiskInfoDto()
        {
            this.Items = new List<DiskInfoItem>();
        }
    }

    [Serializable]
    public class DiskInfoItem
    {
        [JsonProperty("label")]
        public string Label { get; set; }
        [JsonProperty("size")]
        public double Size { get; set; }
        [JsonProperty("freeSpace")]
        public double FreeSpace { get; set; }
        [JsonProperty("diskLoad")]
        public double DiskLoad { get; set; }
    }

    /// <summary>
    /// CPU信息
    /// </summary>
    [Serializable]
    public class CPUInfoDto : BaseHostDto
    {
        [JsonProperty("processorCount")]
        public int ProcessorCount { get; set; }
        [JsonProperty("cpuLoad")]
        public double CpuLoad { get; set; }
    }

    /// <summary>
    /// 内存信息
    /// </summary>
    [Serializable]
    public class MemoryInfoDto : BaseHostDto
    {
        [JsonProperty("available")]
        public double Available { get; set; }
        [JsonProperty("physical")]
        public double Physical { get; set; }
        [JsonProperty("memoryLoad")]
        public double MemoryLoad { get; set; }
    }

    /// <summary>
    /// 网站连接数
    /// </summary>
    [Serializable]
    public class CurrentConnectionDto : BaseHostDto
    {
        [JsonProperty("items")]
        public IList<ConnectionItem> Items { get; set; }

        public CurrentConnectionDto()
        {
            this.Items = new List<ConnectionItem>();
        }
    }

    [Serializable]
    public class ConnectionItem
    {
        [JsonProperty("siteName")]
        public string SiteName { get; set; }
        [JsonProperty("total")]
        public int Total { get; set; }
    }

    [Serializable]
    public class MonitorRequestDto
    {
        [JsonProperty("all")]
        public IList<MonitorRequestItem> Items { get; set; }

        [JsonProperty("last")]
        public DateTime Last { get; set; }

        public MonitorRequestDto()
        {
            this.Items = new List<MonitorRequestItem>();
        }
    }

    [Serializable]
    public class MonitorRequestItem
    {
        [JsonProperty("id")]
        public string Id { get; set; }
        [JsonProperty("type")]
        public string Type { get; set; }
        [JsonProperty("dest")]
        public string Dest { get; set; }
    }

    [Serializable]
    public class MonitorResponseDto
    {
        [JsonProperty("id")]
        public string Id { get; set; }
        [JsonProperty("isOk")]
        public bool IsOk { get; set; }
        [JsonProperty("text")]
        public string Text { get; set; }

        public MonitorResponseDto(string id)
        {
            this.Id = id;
        }
    }
}
